package cn.swufe.edu.stu.hw_tools.Cal;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;

import cn.swufe.edu.stu.hw_tools.R;

public class STableActivity extends AppCompatActivity {
    private Button btn;
    private ArrayList<HashMap<String, String>> listItems;
    private SimpleAdapter listItemAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_stable);

        btn = findViewById(R.id.CC4STback);
        ListView listView = findViewById(R.id.CC4STlist);
        initListView();
        listView.setAdapter(listItemAdapter);


        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent config = getIntent();
                setResult(1,config);
                finish();
            }
        });
    }

    private void initListView() {
        listItems = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("money", "应纳税所得额 " );
            map.put("rate", "3" );
            map.put("direct", "速算扣除数" );
            listItems.add(map);
            HashMap<String, String> map1 = new HashMap<String, String>();
            map1.put("money", "不超过3,000元" );
            map1.put("rate", "10" );
            map1.put("direct", "0" );
            listItems.add(map1);
            HashMap<String, String> map2 = new HashMap<String, String>();
            map2.put("money", "超过3,000元至12,000元" );
            map2.put("rate", "20" );
            map2.put("direct", "210" );
            listItems.add(map2);
            HashMap<String, String> map3 = new HashMap<String, String>();
            map3.put("money", "超过12,000元至25,000元" );
            map3.put("rate", "25" );
            map3.put("direct", "1410" );
            listItems.add(map3);
            HashMap<String, String> map4 = new HashMap<String, String>();
            map4.put("money", "超过25,000元至35,000元" );
            map4.put("rate", "30" );
            map4.put("direct", "2660" );
            listItems.add(map4);
            HashMap<String, String> map5 = new HashMap<String, String>();
            map5.put("money", "超过35,000元至55,000元" );
            map5.put("rate", "35" );
            map5.put("direct", "4410" );
            listItems.add(map5);
            HashMap<String, String> map6 = new HashMap<String, String>();
            map6.put("money", "超过55,000元至80,000元" );
            map6.put("rate", "40" );
            map6.put("direct", "7160" );
            listItems.add(map6);
            HashMap<String, String> map7 = new HashMap<String, String>();
            map7.put("money", "超过80,000元" );
            map7.put("rate", "45" );
            map7.put("direct", "15160" );
            listItems.add(map7);
        // 生成适配器的Item和动态数组对应的元素
        listItemAdapter = new SimpleAdapter(this, listItems, // listItems数据源
                R.layout.st_list_layout, // ListItem的XML布局实现
                new String[] { "money", "rate" ,"direct"},
                new int[] { R.id.STlayout1, R.id.STlayout2, R.id.STlayout3}
        );
    }

}